package com.tianquan.miracle.listener.refreshed;

import com.tianquan.miracle.listener.core.EventListener;

/**
 * @Author: tianquan
 * @date: 2024-10-12  18:45
 */
public class ContextRefreshedEventListener implements EventListener<ContextRefreshedEvent> {

    private boolean use = true;

    @Override
    public void onEvent(ContextRefreshedEvent event) {
        if (!use) {
            return;
        }
        long startTime = event.getStartTime();
        long endTime = event.getEndTime();
        // 时间戳转秒 保留小数后4位
        double time = ((endTime - startTime) * 0.001);
        System.out.println("容器启动时间：" + String.format("%.4f秒", time));
        use = false;
    }

}


